package com.cicc.springboot.entity;

import java.io.Serializable;

import cn.afterturn.easypoi.excel.annotation.Excel;
import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.format.DateTimeFormat;
import com.alibaba.excel.annotation.format.NumberFormat;
import com.alibaba.excel.converters.doubleconverter.DoubleStringConverter;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.cicc.springboot.utile.ExcelDataConverter;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.persistence.Column;
import java.util.Date;
import java.util.List;


@Data
@NoArgsConstructor
@TableName("srm_purchase_order")
public class PurchaseOrderEntity implements Serializable {

    private static final long serialVersionUID = 1L;

    @TableId(value = "id", type = IdType.AUTO)
    @Column(name = "id")
    @ExcelIgnore
    private Long id;

    /**
     * 订单类型
     */
    @Column(name = "order_type")
    @ExcelProperty(value = "订单类型")
    @Excel(name = "订单类型")
    private String orderType;

    /**
     * 采购组编码
     */
    @Column(name = "purchase_group")
    @ExcelProperty(value = "采购组编码")
    @ExcelIgnore
    private String purchaseGroup;

    /**
     * 公司编号
     */
    @Column(name = "company_code")
    @ExcelProperty(value = "公司编号")
    @ExcelIgnore
    private String companyCode;

    /**
     * 公司名称
     */
    @Column(name = "company_name")
    @ExcelProperty(value = "公司名称")
    @ExcelIgnore
    private String companyName;

    /**
     * 供应商编码
     */
    @Column(name = "supplier_code")
    @ExcelProperty(value = "供应商编码")
    @Excel(name = "供应商编码")
    private String supplierCode;

    /**
     * 供应商名称
     */
    @Column(name = "supplier_name")
    @ExcelProperty(value = "供应商名称")
    @Excel(name = "供应商名称")
    private String supplierName;

    /**
     * 订单号
     */
    @Column(name = "order_code")
    @ExcelProperty(value = "订单号", index = 0)
    @Excel(name = "订单号")
    private String orderCode;

    /**
     * 币别
     */
    @Column(name = "order_currency")
    @ExcelProperty(value = "币别")
    @Excel(name = "币别")
    private String orderCurrency;

    /**
     * 抬头文本
     */
    @Column(name = "head_text")
    @ExcelProperty(value = "抬头文本")
    @ExcelIgnore
    private String headText;

    /**
     * 订单日期
     */
    @Column(name = "order_date")
    @ExcelProperty(value = "订单日期", converter = ExcelDataConverter.class)
    @DateTimeFormat("yyyy-MM-dd HH:mm:ss")  //定义日期格式
    @Excel(name = "订单日期")
    private Date orderDate;

    /**
     * 订单会计年度
     */
    @Column(name = "order_year")
    @ExcelProperty(value = "会计年度")
    @Excel(name = "会计年度")
    private String orderYear;

    /**
     * 采购组织编码
     */
    @Column(name = "purchase_org")
    @ExcelProperty(value = "采购组织编码")
    @ExcelIgnore
    private String purchaseOrg;

    /**
     * 创建人
     */
    @Column(name = "create_by")
    @ExcelProperty(value = "创建人")
    @ExcelIgnore
    private String createBy;

    /**
     * 修改人
     */
    @Column(name = "update_by")
    @ExcelProperty(value = "修改人")
    @ExcelIgnore
    private String updateBy;

    /**
     * 创建时间
     */
    @Column(name = "create_time")
    @ExcelProperty(value = "创建时间", converter = ExcelDataConverter.class)
    @DateTimeFormat("yyyy-MM-dd HH:mm:ss")  //定义日期格式
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @ExcelIgnore
    private Date createTime;

    /**
     * 更新时间
     */
    @Column(name = "update_time")
    @ExcelProperty(value = "更新时间", converter = ExcelDataConverter.class)
    @DateTimeFormat("yyyy-MM-dd HH:mm:ss")  //定义日期格式
    @ExcelIgnore
    private Date updateTime;

    /**
     * 租户ID
     */
    @Column(name = "tenant_id")
    @ExcelProperty(value = "租户ID")
    @ExcelIgnore
    private Long tenantId;

    /**
     * 删除标记
     */
    @Column(name = "delete_flag")
    @ExcelProperty(value = "删除标记")
    @ExcelIgnore
    private String deleteFlag;

    /**
     * 订单创建人
     */
    @Column(name = "order_creater")
    @ExcelProperty(value = "订单创建人")
    @ExcelIgnore
    private String orderCreater;

    /**
     * 付款条件
     */
    @Column(name = "pay_type")
    @ExcelProperty(value = "付款条件")
    @ExcelIgnore
    private String payType;

    /**
     * 修改类型(U表示更新，I表示插入，E表示删除单个字段，D表示删除整行或整个单据)
     */
    @Column(name = "change_type")
    @ExcelProperty(value = "修改类型")
    @ExcelIgnore
    private String changeType;

    /**
     * 国际贸易条款
     */
    @Column(name = "inter_trade_code")
    @ExcelProperty(value = "国际贸易条款")
    @ExcelIgnore
    private String interTradeCode;

    /**
     * 1.全部确认;2.部分确认;3.已拒绝;4.待确认;5.草稿
     */
    @Column(name = "state")
    @ExcelProperty(value = "订单状态")
    @ExcelIgnore
    private String state;

    /**
     * 关联租户id
     */
    @Column(name = "ref_tenant_id")
    @ExcelProperty(value = "关联租户id")
    @ExcelIgnore
    private Long refTenantId;

    /**
     * 对应的销售订单同步状态描述
     */
    @Column(name = "so_sync_status")
    @ExcelProperty(value = "对应的销售订单同步状态描述")
    @ExcelIgnore
    private String soSyncStatus;

    /**
     * 平台订单类型
     */
    @Column(name = "platform_order_type")
    @ExcelProperty(value = "平台订单类型")
    @ExcelIgnore
    private String platformOrderType;

    /**
     * 供应商发布ASN(0不发布，1发布）
     */
    @Column(name = "publish_asn")
    @ExcelProperty(value = "供应商发布ASN(0不发布，1发布）")
    @ExcelIgnore
    private String publishAsn;

    /**
     * 是否需要确认 0否 1是
     */
    @Column(name = "need_confirm")
    @ExcelProperty(value = "是否需要确认")
    @ExcelIgnore
    private String needConfirm;

    /**
     * 订单总价（含税）
     */
    @Column(name = "total_price_with_tax")
    @ExcelProperty(value = "订单总价")
    @NumberFormat("#.##")
    @ExcelIgnore
    private Double totalPriceWithTax;

    /**
     * 订单总价（不含税）
     */
    @Column(name = "total_price_without_tax")
    @ExcelProperty(value = "订单总价（不含税）", converter = DoubleStringConverter.class)
    @ExcelIgnore
    private Double totalPriceWithoutTax;

    /**
     * 订单来源
     */
    @Column(name = "source")
    @ExcelProperty(value = "订单来源")
    @ExcelIgnore
    private String source;

    /**
     * 确认时间
     */
    @Column(name = "confirm_time")
    @ExcelProperty(value = "确认时间", converter = ExcelDataConverter.class)
    @DateTimeFormat("yyyy-MM-dd HH:mm:ss")  //定义日期格式
    @ExcelIgnore
    private Date confirmTime;

    /**
     * 附件id
     */
    @Column(name = "batch_id")
    @ExcelProperty(value = "附件id")
    @ExcelIgnore
    private String batchId;

    /**
     * 采购组描述
     */
    @Column(name = "purchase_group_desc")
    @ExcelProperty(value = "采购组")
    @Excel(name = "采购组")
    private String purchaseGroupDesc;

    /**
     * 采购组织描述
     */
    @Column(name = "purchase_org_desc")
    @ExcelProperty(value = "采购组织")
    @Excel(name = "采购组织")
    private String purchaseOrgDesc;

    /**
     * 采购订单类型描述
     */
    @Column(name = "order_type_desc")
    @ExcelProperty(value = "订单类型描述")
    @ExcelIgnore
    private String orderTypeDesc;

    /**
     * 退货标识
     */
    @Column(name = "is_return")
    @ExcelProperty(value = "退货标识")
    @ExcelIgnore
    private String isReturn;

    /**
     * 订单标识
     */
    @Column(name = "order_description")
    @ExcelProperty(value = "订单标识")
    @ExcelIgnore
    private String orderDescription;

    /**
     * 订单备注
     */
    @Column(name = "order_notes")
    @ExcelProperty(value = "订单备注")
    @Excel(name = "订单备注")
    private String orderNotes;

    /**
     * 订单明细的list集合
     */
    @TableField(exist = false)
    @ExcelIgnore
    private List<OrderItemEntity> orderDetails;

}
